
export default function reducer( state = '', action:any ){
    //1.深拷贝state,得到一个全新的state
    state = JSON.parse( JSON.stringify( state ) );
    
    //2.判断action的类型,执行不同的数据操作
    if( action.type == 'SAVE_id'){
        state = action.payload;
    }
    else if( action.type == 'REMOVE_id' ){
        state = '';
    }

    //3.返回一个全新的state
    return state;
}